package com.sdsy.blockchaintrainingback.service.network;

import com.sdsy.blockchaintrainingback.mapper.network.NetworkMapper;
import com.sdsy.blockchaintrainingback.pojo.network.Network;
import com.sdsy.blockchaintrainingback.service.docker.DockerService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * @Description TODO
 * @Author linzili
 * @Date 2023/9/27 18:55
 * @Version 1.0
 */
@Service
public class NetworkServiceImpl implements NetworkService{
    @Resource
    private DockerService dockerService;

    @Resource
    private NetworkMapper networkMapper;
    @Override
    public Boolean createNetwork(String name, String subnet) {
        String networkId = dockerService.createNetwork(name, subnet);
        Network network = new Network();
        network.setNetworkId(networkId);
        network.setName(name);
        network.setSubnet(subnet);
        networkMapper.insert(network);
        return true;
    }
}
